// 引入发送请求的promise方法
import {request} from '../../request/index'
//Page Object
Page({
    data: {
        // 轮播图数据
        swiperList: [],
        navList: [],
        floorList: []
    },
    
    onLoad: function(options){
        this.getSwiperList();
        this.getNavList();
        this.getFloorList();
    },
    onReady: function(){
        
    },
    onShow: function(){
        
    },
    onHide: function(){

    },
    onUnload: function(){

    },
    onPullDownRefresh: function(){

    },
    onReachBottom: function(){

    },
    onShareAppMessage: function(){

    },
    onPageScroll: function(){

    },
    onTabItemTap:function(item){

    },

    // 获取轮播图数据
    async getSwiperList() {
        try{
            const {data:res} = await request({url:'/home/swiperdata'});
            this.setData({
                swiperList: res.message
            })
        }catch(e){
            console.log(e);
        }
    },
    // 获取导航菜单数据
    async getNavList() {
        try{
            const {data:res} = await request({url:'/home/catitems'});
            const listData = res.message;
            this.setData({
                navList: listData
            })
        }catch(e){
            console.log(e);
        }
    },
    //获取楼层模块数据
    async getFloorList() {
        try{
            const {data:res} = await request({url:'/home/floordata'});
            this.setData({
                floorList: res.message
            })
        }catch(e){
            console.log(e);
        }
    },
});